home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ABUSESRC.ZIP / AbuseSrc / macabuse / inc / tiles.hpp < prev    next >
Text File  |  1997-05-20  |  1KB  |  71 lines

  1. class tile
  2. {
  3.   uchar *im_data;
  4.   uchar *run_data;
  5.   boundary *points;
  6.   ushort next;
  7.   public :
  8.   tile(bFILE *fp, int type);
  9. } ;
  10.  
  11.  
  12. tile::tile(bFILE *fp, int type, int w, int h)
  13.   int cw=fp->read_short(),ch=fp->read_short();
  14.   if (cw!=w || ch!=h)
  15.   {
  16.     lbreak("load_tiles : expecting tile size to be %dx%d, got %dx%d\n",w,h,cw,ch);
  17.     exit(0);
  18.   }
  19.  
  20.   im_data=(uchar *)jmalloc(w*h,"tile image");
  21.   fp->read(im_data,w*h);
  22.   
  23.   if (type==SPEC_FORETILE)
  24.   {
  25.     next=fp->read_short();  // next
  26.     fp->read_byte();        // skip damage, not implemented
  27.     points=new boundary(fp,"tile boundary");
  28.     uchar *c=im_data;
  29.     int need_runs=0;
  30.  
  31.     if (need_runs)
  32.       run_data=make_runs(im_data,w,h);
  33.     } else run_data=NULL;
  34.   } else { points=NULL; run_data=NULL; }    
  35. }
  36.  
  37. class tile_set
  38. {
  39.   public :
  40.   int w,h,t;
  41.   int *id;
  42.   tile_set *next;
  43.   tile_set(int width, int height);  
  44.   void add(int tile_id, int tile_number);
  45. } ;
  46.  
  47.  
  48. tile_set::tile_set(int width, int height, tile_set *Next)
  49. {
  50.   w=width;
  51.   h=height;
  52.   t=0;
  53.   next=Next;
  54.   id=NULL;
  55. }
  56.  
  57.  
  58. void tile_set::add(int tile_id, int tile_number)
  59. {
  60.   if (tile_number>=t)
  61.   {
  62.     id=(int *)jrealloc(id,sizeof(int)*tile_number,"tile set list");
  63.     t=tile_number;
  64.   }
  65.   id[tile_number]=tile_id;    
  66. }
  67.  
  68.  
  69.  
  70.